function blockPage(){
	$("body").append("<div class='cover_prevent_div'>&nbsp;</div>");
}

function documentLocationFixed(loc) {
	if($.browser.msie && $.browser.version.substr(0,1)<10){
		var b = document.getElementsByTagName('base');
		if (b && b[0] && b[0].href) {
			if (b[0].href.substr(b[0].href.length - 1) == '/'
					&& loc.charAt(0) == '/')
				loc = loc.substr(1);
			loc = b[0].href + loc;
		}
	}
	document.location = loc;
}

function cancelProcess(appId){
	$.fancybox.showLoading();
	$.post("cancelProcess/"+appId)
	.success(
			function(data){
				documentLocationFixed("admin/general/inbox/tasks/show.htm");
			})
	.error(function() {
		$.fancybox.hideLoading();
		jAlert('error', 'Unable to cancel request',
		'Error');
	});
	return false;
}

function updateTaskAndNotificationsCount(){
	$.getJSON("getUserTaskAndNotificationsCount.json", function(data){
		$("#newTasksCount").html(data.newTasks);
		$("#newNotificationsCount").html(data.newNotifications);
	});
}


function fancyAlert(msg) {
	jQuery.fancybox({
	'modal' : true,
	'content' : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input class=\"button_small\" style=\"margin:3px;padding:0px;\" type=\"button\" onclick=\"jQuery.fancybox.close();\" value=\"Ok\"></div></div>"
	});
	}
	 
function fancyConfirm(msg,cancelBtnText,OKBtnText,callback) {
		var ret;
		jQuery.fancybox({
			'modal' : true,
			'height' : '100px',
			'maxHeight':'120px',
			'content' : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input id=\"fancyConfirm_cancel\" class=\"button_small\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\""+cancelBtnText+"\"><input id=\"fancyConfirm_ok\" class=\"button_small\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\""+OKBtnText+"\"></div></div>",
			afterShow : function() {
				$("#fancyConfirm_cancel").click(function() {
					ret = false;
					jQuery.fancybox.close();
				});
				
				$("#fancyConfirm_ok").click(function() {
					ret = true;
					jQuery.fancybox.close();
				});
			},
			afterClose : function() {
				if (typeof callback == 'function'){ callback.call(this, ret); }
			}
		});
}